//1314.矩阵区域和
#include<iostream>
#include<vector>
using namespace std;

vector<vector<int>> matrixBlockSum(vector<vector<int>>& mat,int k){
    //预处理前缀和数组
    vector<vector<int>> dp(mat.size() + 1, vector<int>(mat[0].size() + 1));
    //先处理行数下标为0和列数下标为0的情况
    for (int i = 0; i < mat.size()+1;i++){
        dp[i][0] = 0;
    }
    for (int j = 0; j < mat[0].size()+1;j++){
        dp[0][j] = 0;
    }

    for (int i = 1; i < mat.size() + 1;i++){
        for (int j = 1; j < mat[0].size() + 1;j++){
            dp[i][j] = dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1] + mat[i - 1][j - 1];
        }
    }

    //使用前缀和数组
    vector<vector<int>> ret(mat.size(), vector<int>(mat[0].size()));
    for (int i = 0; i < mat.size();i++){
        for (int j = 0; j < mat[0].size();j++){
            int x1 = max(0, i - k) + 1;
            int y1 = max(0, j - k) + 1;
            int x2 = min((int)mat.size() - 1, i + k) + 1;
            int y2 = min((int)mat[0].size() - 1, j + k) + 1;

            ret[i][j] = dp[x2][y2] - dp[x1 - 1][y2] - dp[x2][y1 - 1] + dp[x1 - 1][y1 - 1];
        }
    }

    return ret;
}

int main(){
    int n = 0, m = 0, k = 0;
    cin >> n >> m >> k;

    vector<vector<int>> vv(n, vector<int>(m));
    for (int i = 0; i < n;i++){
        for (int j = 0; j < m;j++){
            cin >> vv[i][j];
        }
    }

    vector<vector<int>> ret = matrixBlockSum(vv, k);
    
    for(auto v : ret){
        for(auto x : v){
            cout << x << " ";
        }
        cout << endl;
    }

    return 0;
}